﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Common.Aliyun
{
    /// <summary>
    /// 阿里云客户端诊断数据
    /// </summary>
    public class AliyunDiagnosticData
    {
        /// <summary>
        /// 日志消息
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 异常信息
        /// </summary>
        public Exception Exception { get; set; }
    }

    internal static class DiagnosticHelper
    {
        private static DiagnosticListener diagnostic = new DiagnosticListener("Common.Aliyun");
        public static void Write(string key, string message)
        {
            Write(key, new AliyunDiagnosticData { Message = message });
        }
        public static void Write(string key, string message, Exception ex)
        {
            Write(key, new AliyunDiagnosticData { Message = message, Exception = ex });
        }
        public static void Write(string key, object val)
        {
            diagnostic.Write(key, val);
        }
    }
}
